<%@page import="com.easyattendance.model.Material"%>
<%@page import="com.easyattendance.model.MaterialClass"%>
<%@page import="com.easyattendance.services.AddProxyService"%>

<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>

<%@ page import ="com.easyattendance.services.AddTeacherService" %>
<%@ page import ="com.easyattendance.model.Teacher" %>
<%@ page import ="com.easyattendance.model.Subject" %>
<%@ page import ="com.easyattendance.model.SubjectClass" %>
<%@ page import="com.easyattendance.services.AddClassService" %>
<%@ page import="com.easyattendance.services.AddSubjectService" %>
<%@ page import="com.easyattendance.services.AddMaterialService" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Student - View Syllabus </title>

<!-- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> -->
<jsp:include page="../includeFiles.jsp" />
	
<link rel="stylesheet" href="<%=request.getContextPath()%>/views/css/ui/jquery-ui-1.10.4.custom.min.css">
<script src="<%=request.getContextPath()%>/public/js/ui/jquery.ui.core.js"></script>
<script src="<%=request.getContextPath()%>/public/js/ui/jquery.ui.widget.js"></script>
<script src="<%=request.getContextPath()%>/public/js/ui/jquery.ui.accordion.js"></script>
<script>
	/* If want to fix height inner content of accordion - 
		remove 'heightStyle' line (and the above comma too :p ).
	*/
	$(function() {
		$( "#accordion" ).accordion({
			collapsible: true,
			heightStyle: "content",
		});
	});
</script>

</head>

<body class="left-sidebar">

<!-- Session check : user logged in or not/ press back button -->
<jsp:include page="../common/checkSession.jsp" />
<jsp:include page="../common/checkStudentRole.jsp" />

<% 
	String currentUser = (String) session.getAttribute("currentUser");
	AddTeacherService addTeacherService = new AddTeacherService();
	AddClassService addClassService = new AddClassService();
	
	AddSubjectService addSubjectService = new AddSubjectService();
	AddMaterialService addMaterialService = new AddMaterialService();

	String classId = addClassService.getClassByClassEmailId(currentUser).getClass_id();
	List<Subject> subjects=new ArrayList<Subject>(); %>


<div id="wrapper">

		<!-- Content -->
		<div id="content">
			<div id="content-inner">
				<header>
					<center><h2>Syllabus List</h2></center>
				</header>
	    	 			<div id="accordion" style="clear:both;">
		    	 			<% 
					   			 subjects=addSubjectService.listSubjectsByClassId(classId);
					   			 for(Iterator subItr=subjects.iterator();subItr.hasNext();) { 
				  						 Subject tempSubject=(Subject)subItr.next(); 
				  						 
				  						 List<Material> syllabusList=new ArrayList<Material>(); 
				  						 syllabusList=addMaterialService.listSyllabusBySubject(tempSubject.getSubject_id(),classId); %>
				  						 
				  				   		 
				  				   		     <h3><%=tempSubject.getSubject_name() %></h3>
				  				   		     <div>
				  				   		     <%  int i=0;
				  				   		     	if(syllabusList!=null){ %>
				  				   		      <%  for(Iterator syll_Itr=syllabusList.iterator();syll_Itr.hasNext();) {
				  				   		    	     i++;
				  				   		    	     Material tempMaterial=(Material)syll_Itr.next();  
				  			   		    	     
				  				   		    	     %>
				  				   		    	 
				  				   		    	 <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
				  				   		    	  <%=i %>)   <a href="${pageContext.request.contextPath}/DownloadFileServlet?path=<%=tempMaterial.getPhysical_path()%>"><%=tempMaterial.getMaterial_name()%></a>   
				  				   		       <%} %>  
										     <%} %>
										     </div>		
							 <% }%>
						</div>
		</div>
  </div>
  
		<!-- Sidebar -->
	      <div id="sidebar">    

			<!-- Sidebar Header - Logo & Name -->
			  <jsp:include page="../common/sidebarHeader.jsp" /> 

			<jsp:include page="studentMenu.jsp" />  
			
			<!-- Sidebar Footer Content -->
				 <jsp:include page="../common/sidebarFooter.jsp" />

		</div>  

	</div>	
	<script type="text/javascript">
		$(function(){
			$("#viewSyllabus").addClass("current_page_item");
		});
	</script>
	
</body>
</html>